package com.ddwl.user.dao.mapper;

import com.ddwl.common.dao.mapper.TkMapper;
import com.ddwl.schema.bo.user.UserSearchBo;
import com.ddwl.schema.vo.order.StatisticsUserVo;
import com.ddwl.schema.vo.user.UserVo;
import com.ddwl.user.dao.model.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author Fu Zhaohui
 * @version 1.0.0
 * @date 2019/6/12 13:42
 */
@Repository
public interface UserMapper extends TkMapper<User> {


    /**
     * 移除用户代理信息
     * @param userId
     */
    @Update("UPDATE sys_user SET profit_level = null WHERE id = #{userId} ")
    void removeUserDist(String userId);

    /**
     * 修改直接上级昵称
     * @param userId
     * @param nickname
     */
    @Update("UPDATE sys_user SET immediate_superior_name = #{nickname} WHERE immediate_superior = #{userId} ")
    void updateImmediateSuperiorNickname(String userId, String nickname);
    /**
     * 修改间接上级昵称
     * @param userId
     * @param nickname
     */
    @Update("UPDATE sys_user SET indirect_superior_name = #{nickname} WHERE indirect_superior = #{userId} ")
    void updateIndirectSuperiorName(String userId, String nickname);


    void updateNameAndBir(@Param("user") User user);

    /**
     * 升级区域经理
     * @param entity
     */
    void upToReionBoss(@Param("user") User entity);

    /**
     * 修改用户上级属性
     * @param directSub
     */
    void updateSuperiorField(@Param("user") User directSub);

    List<StatisticsUserVo> queryUserCount(UserSearchBo bo);

    void changeUserLevelId(@Param("map") Map<String, String> map);

    UserVo getByOpenId(@Param("openId") String openId,@Param("pk")String pk);
}
